package org.apache.dubbo.engine.loadbalance;

import java.util.List;
import java.util.Random;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.cluster.loadbalance.AbstractLoadBalance;

/**
 * @author liangcai_zhu
 * @Description TODO
 * @Date 2019/12/13 15:09
 */
public class FirstLoadBalance extends AbstractLoadBalance {
  public static final String NAME = "first";
  public static final Random random = new Random();
  @Override
  protected <T> Invoker<T> doSelect(List<Invoker<T>> invokers, URL url, Invocation invocation) {

    System.out.println(NAME+url.getAbsolutePath());
    return invokers.get(random.nextInt(invokers.size()));
  }
}
